import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
import main from '../components/main.vue';
import login from "../components/login.vue";
import home from "../components/home.vue";
import show from "../components/show.vue";
import admin from "../components/admin.vue";
import mcpManage from "../components/mcpManage.vue";
import commentsManage from "../components/commentsManage.vue";
import use from "../components/use.vue";



const routes: Array<RouteRecordRaw> = [
    {
        path: '/mainsdgery4y43ydsgefst',
        name: 'main',
        component: main,
        // 如果你需要meta信息，可以这样写，注意meta的类型是Record<string, any>或更具体的类型
        // meta: { requiresAuth: true },
        children: [
            {path: '/', name: 'home', component: home, meta: { title: 'MCP SPACE-中文MCP空间站' }},
            {path: '/show', name: 'show', component: show, meta: { title: 'MCP SPACE-Server/Client详细信息' }},
            {path: '/use', name: 'use', component: use, meta: { title: 'MCP SPACE-Server Client使用说明' }},
        ]
    },
    {
        path: '/admingaugyf7f8fgff',
        name: 'admin',
        component: admin,
        // 如果你需要meta信息，可以这样写，注意meta的类型是Record<string, any>或更具体的类型
        // meta: { requiresAuth: true },
        children: [
            {path: '/mcpManage', name: 'mcpManage', component: mcpManage, meta: { title: 'MCP 管理' }},
            {path: '/commentsManage', name: 'commentsManage', component: commentsManage, meta: { title: 'MCP 评论管理' }},
        ]
    },
    {
        path: '/mcpLogin',
        name: 'login',
        component: login,
        meta: { title: 'MCP - SPACE 管理登录' }
    }

];


const router = createRouter({
    history: createWebHistory(),
    routes
});

router.beforeEach((to, from, next) => {
  // 修改页面标题
  if (to.meta && to.meta.title) {
    document.title = to.meta.title;
  }
  next();
});

export default router;